package cn.yunhe.biz;

import cn.yunhe.bean.User;
import cn.yunhe.dao.UserMapper;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserService {

    SqlSession session = SqlSessionFactoryUtil.getSqlSession();
    UserMapper userMapper = session.getMapper(UserMapper.class);

    public User loginUser(User user) {
        return userMapper.loginUser(user);
    }

    public int addUser(User user) {
        int flag = userMapper.addUser(user);
        session.commit();
        return flag;
    }

    public List<User> getAllUser(){
        return userMapper.getAllUser();
    }

    public int deleteUserById(int userId){
        int flag= userMapper.deleteUserById(userId);
        session.commit();
        return flag;
    }
}

